package com.example.huahanshu2;

import static Utils.MyUtils.loadWinSize;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import Utils.MyHelpDraw;

public class CanvasView extends View {

    private Paint mGridPaint;//网格画笔
    private Point mWinSize;//屏幕尺寸
    private Point mCoo;//坐标系原点
    private int flag=1;//标记坐标轴单位1为100,2为10

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    public CanvasView(Context context) {
        super(context);
    }
    public CanvasView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        //TODO init 初始化
        mWinSize = new Point();
        mCoo = new Point(500, 900);
        loadWinSize(getContext(), mWinSize);
        mGridPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//TODO drawGrid 绘制网格：release：
        MyHelpDraw.drawGrid(canvas, mWinSize, mGridPaint);
//TODO drawCoo 绘制坐标系:release：
        MyHelpDraw.drawCoo(canvas, mCoo, mWinSize, mGridPaint,flag);
    }



}
